package com.taihe.thread;

/**
 * Created by zwt on 2018/10/31.
 * 生产产品的类
 */
public class Product extends Thread{

    private Breads bre;

    //无参构造
    public Product() {
        super();
    }

    //有参构造
    public Product(Breads bre) {
        super();
        this.bre = bre;
    }


    //set和get方法
    public Breads getBre() {
        return bre;
    }

    public void setBre(Breads bre) {
        this.bre = bre;
    }

    //继承重写run方法
    @Override
    public void run() {
        pro();
    }

    private void pro() {
        for (int i = 0; i <20; i++) {
            try {
                //沉睡0.3秒（演示效果需要，可以不加）
                Thread.currentThread().sleep(300);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            bre.product();
        }
    }
}
